package com.ofsoft.weixin.app.api;

import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.ofsoft.weixin.core.OkHttp;

public class UserInfo {
	private static String jsCode2sessionUrl = "https://api.weixin.qq.com/sns/jscode2session";

	/**
	 * 获取sessionKey
	 * 
	 * @param jsCode
	 *            登录时获取的 code
	 * @return ApiResult
	 */
	public Map<String, Object> getSessionKey(String jsCode, String appid,
			String secret) {
		String url = jsCode2sessionUrl + "?appid=" + appid + "&secret="
				+ secret + "&js_code=" + jsCode
				+ "&grant_type=authorization_code";
		// 构造url
		String json = OkHttp.okHttpGet(url);
		return JSON.parseObject(json);
	}
}
